#include <QtGui/QApplication>
#include "fwtest.h"

void ThreadFunction(void* UserData)
{
    // Print something...
    for (int i = 0; i < 10; ++i)
        std::cout << "I'm the thread number 1" << std::endl;
	 sf::RenderWindow App(sf::VideoMode(1080, 720, 32), "SFML Graphics");

	 sf::Image Image;
	 sf::Sprite Sprite;
	 Image.LoadFromFile("titlescreen.jpg");
	 Sprite.SetImage(Image);
	 float moveX = 0;
	 Sprite.SetPosition(0,0);
    
    // Start game loop
    while (App.IsOpened())
	{
		// Process events
		sf::Event Event;
		while (App.GetEvent(Event))
		{
			// Close window : exit
			if (Event.Type == sf::Event::Closed)
				App.Close();
		}
		

		float ElapsedTime = App.GetFrameTime();
		// Clear the screen (fill it with black color)
		App.Clear();
		//moveX+=0.00001f;
		//moveX*=ElapsedTime;
		
		Sprite.Move(moveX,0);
		App.Draw(Sprite);
		// Display window contents on screen
		App.Display();
	}
	exit(0);
}



int main(int argc, char *argv[])
{
	sf::Thread Thread(&ThreadFunction);
	
	// Start it !
	Thread.Launch();

	QApplication a(argc, argv);
	fwtest w;
    fwtest *k;
	k = &w;
	w.show();

	a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
	return a.exec();

	
	
}
